C51 COMPILER V9.60.0.0   MAIN                                                              02/13/2023 14:16:32 PAGE 1   


C51 COMPILER V9.60.0.0, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Release\main.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE main.c OPTIMIZE(0,SPEED) REGFILE(.\Release\Sample_DrvCAP.ORC) BROWSE INC
                    -DIR(..\..\..\..\C51SIS\C51;..\..\..\Include\Driver) DEBUG OBJECTEXTEND TABS(2) OBJECT(.\Release\main.obj)

line level    source

   1          /**************************************************************************//**
   2           * @file           main.c
   3           * @version        V1.0
   4           * $Revision:      1 $
   5           * $Date:          2017/01/04 $
   6           * @brief          Main function
   7           * @Author         Jeffrey Kang
   8           * @ContactInfo    chkang@esmt.com.tw
   9           *
  10           * @note
  11           *
  12           * Copyright (C) 1998 Elite Semiconductor Memory Technology Corp.
  13           * All rights reserved.
  14           *
  15           ******************************************************************************/
  16          
  17          
  18          #include <REG52.h>
  19          #include "system_FE81001.h"
  20          
  21          
  22          static volatile unsigned char xdata cap0_cnt[2];
  23          static volatile unsigned char xdata cap1_cnt[2];
  24          static volatile unsigned char xdata cap2_cnt[2];
  25          static volatile unsigned char xdata cap3_cnt[2];
  26          
  27          
  28          /**
  29           * @brief       delay function
  30           *
  31           * @param       None
  32           *
  33           * @return      None
  34           *
  35           * @details     1. 
  36           */
  37          void delay( void )
  38          {
  39   1        unsigned int i;
  40   1        
  41   1        for( i = 0 ; i < 1000 ; i++ ){}
  42   1      }
  43          
  44          
  45          /**
  46           * @brief       EINT0ISR function
  47           *
  48           * @param       None
  49           *
  50           * @return      None
  51           *
  52           * @details     1. 
  53           */
  54          const void CAPISR (void) interrupt ISR_CAP
C51 COMPILER V9.60.0.0   MAIN                                                              02/13/2023 14:16:32 PAGE 2   

  55          {
  56   1        /* read for clear interrupt flag */
  57   1        unsigned char int_stat = CAP->capintf;
  58   1        
  59   1        /* capture 0 interrupt */
  60   1        if ((int_stat & 0x01) == 0x01){
  61   2          cap0_cnt[0] = CAP->cap0_cnt[0];
  62   2          cap0_cnt[1] = CAP->cap0_cnt[1];
  63   2        }
  64   1        
  65   1        /* capture 1 interrupt */
  66   1        if ((int_stat & 0x04) == 0x04){
  67   2          cap1_cnt[0] = CAP->cap1_cnt[0];
  68   2          cap1_cnt[1] = CAP->cap1_cnt[1];
  69   2        }
  70   1        
  71   1        /* capture 2 interrupt */
  72   1        if ((int_stat & 0x10) == 0x10){
  73   2          cap2_cnt[0] = CAP->cap2_cnt[0];
  74   2          cap2_cnt[1] = CAP->cap2_cnt[1];
  75   2        }
  76   1        
  77   1        /* capture 3 interrupt */
  78   1        if ((int_stat & 0x40) == 0x40){
  79   2          cap3_cnt[0] = CAP->cap3_cnt[0];
  80   2          cap3_cnt[1] = CAP->cap3_cnt[1];
  81   2        }
  82   1        
  83   1        /* enable global interrupt */
  84   1        INTC->int_gmask = 0x01;
  85   1      }
  86          
  87          
  88          /**
  89           * @brief       EINT3Init function
  90           *
  91           * @param       None
  92           *
  93           * @return      None
  94           *
  95           * @details     1. 
  96           */
  97          void CAP3Init(void)
  98          {
  99   1        /* enable PD.3 input */
 100   1        PD->gpio_ms[0] &= 0xF7;
 101   1        PD->gpio_ms[1] &= 0xF7;
 102   1        PD->gpio_ms[2] &= 0xF7;
 103   1        
 104   1        /* enable PD.3 CAP function */
 105   1        PD->gpio_ctrl[0] |= 0x08;
 106   1        PD->gpio_ctrl[1] &= 0xF7;
 107   1        
 108   1        /* capture config */
 109   1        CAP->prescale = 0;  //  PCLK / (PRESCALE + 1)
 110   1        Set_CAP3_LPF_1();
 111   1        Set_CAP3_Mode_Edge();
 112   1        Enable_Cap3_interrupt();
 113   1        Enable_CAP3();
 114   1      }
 115          
 116          
C51 COMPILER V9.60.0.0   MAIN                                                              02/13/2023 14:16:32 PAGE 3   

 117          /**
 118           * @brief       EINT2Init function
 119           *
 120           * @param       None
 121           *
 122           * @return      None
 123           *
 124           * @details     1. 
 125           */
 126          void CAP2Init(void)
 127          {
 128   1        /* enable PD.2 input */
 129   1        PD->gpio_ms[0] &= 0xFB;
 130   1        PD->gpio_ms[1] &= 0xFB;
 131   1        PD->gpio_ms[2] &= 0xFB;
 132   1        
 133   1        /* enable PD.2 CAP function */
 134   1        PD->gpio_ctrl[0] |= 0x04;
 135   1        PD->gpio_ctrl[1] &= 0xFB;
 136   1        
 137   1        /* capture config */
 138   1        CAP->prescale = 0;  //  PCLK / (PRESCALE + 1)
 139   1        Set_CAP2_LPF_1();
 140   1        Set_CAP2_Mode_Edge();
 141   1        Enable_Cap2_interrupt();
 142   1        Enable_CAP2();
 143   1      }
 144          
 145          
 146          /**
 147           * @brief       EINT1Init function
 148           *
 149           * @param       None
 150           *
 151           * @return      None
 152           *
 153           * @details     1. 
 154           */
 155          void CAP1Init(void)
 156          {
 157   1        /* enable PD.1 input */
 158   1        PD->gpio_ms[0] &= 0xFD;
 159   1        PD->gpio_ms[1] &= 0xFD;
 160   1        PD->gpio_ms[2] &= 0xFD;
 161   1        
 162   1        /* enable PD.1 CAP function */
 163   1        PD->gpio_ctrl[0] |= 0x02;
 164   1        PD->gpio_ctrl[1] &= 0xFD;
 165   1        
 166   1        /* capture config */
 167   1        CAP->prescale = 0;  //  PCLK / (PRESCALE + 1)
 168   1        Set_CAP1_LPF_1();
 169   1        Set_CAP1_Mode_Edge();
 170   1        Enable_Cap1_interrupt();
 171   1        Enable_CAP1();
 172   1      }
 173          
 174          
 175          /**
 176           * @brief       EINT0Init function
 177           *
 178           * @param       None
C51 COMPILER V9.60.0.0   MAIN                                                              02/13/2023 14:16:32 PAGE 4   

 179           *
 180           * @return      None
 181           *
 182           * @details     1. 
 183           */
 184          void CAP0Init(void)
 185          {
 186   1        /* enable PD.0 input */
 187   1        PORT_SetPDInput(BIT0);
 188   1        
 189   1        /* enable PD.0 CAP function */  
 190   1        Set_PD0_CAP0();
 191   1        
 192   1        /* capture config */
 193   1        CAP->prescale = 0;  //  PCLK / (PRESCALE + 1)
 194   1        Set_CAP0_LPF_1();
 195   1        Set_CAP0_Mode_Edge();
 196   1        Enable_Cap0_interrupt();
 197   1        Enable_CAP0();
 198   1      }
 199          
 200          
 201          /**
 202           * @brief       main function
 203           *
 204           * @param       None
 205           *
 206           * @return      None
 207           *
 208           * @details     1. 
 209           */
 210          int main( void )
 211          {
 212   1        /* enable GPIO clock */
 213   1        PORT_PAPBPCPD_Clock_Enable();   // enable GPIOA GPIOB GPIOC GPIOD clock
 214   1        
 215   1        /* enable capture clock */
 216   1        En_CAP_clk();   // external capture clock
 217   1        
 218   1        /* enable cap0 function */
 219   1        CAP0Init();
 220   1        
 221   1        /* enable cap1 function */
 222   1        CAP1Init();
 223   1        
 224   1        /* enable cap2 function */
 225   1        CAP2Init();
 226   1        
 227   1        /* enable cap3 function */
 228   1        CAP3Init();
 229   1        
 230   1        /* enable global interrupt */
 231   1        INTC->int_gmask = 0x01;
 232   1        
 233   1        while(1)
 234   1        {
 235   2          
 236   2        }
 237   1      }
 238          


C51 COMPILER V9.60.0.0   MAIN                                                              02/13/2023 14:16:32 PAGE 5   

MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    752    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      8    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
